﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Carbon.Web.Forms.Controls;
using Carbon.Web.Forms.Extensions;
using Demo.Extensions;
using Carbon.Web.Forms;

namespace Demo.Demos
{
    public partial class SumMatrix : DemoPage
    {
        protected DataContextControlSumMatrix ctrl_SumMatrix = null;
        public DataContextControlSumMatrix Control_SumMatrix
        {
          get
          {
                if (ctrl_SumMatrix == null) throw new NullReferenceException();
                return ctrl_SumMatrix;
          }
        }
        
        protected void AddRow_Click(object sender, EventArgs args)
        {
            Control_SumMatrix.ViewModel.AddRow();
        }
        
        protected void AddColumn_Click(object sender, EventArgs args)
        {
            Control_SumMatrix.ViewModel.AddColumn();
        }

        protected void Validate_All(object sender, EventArgs args)
        {
            Control_SumMatrix.ViewModel.ValidateAll();
        }
        
        protected void DoSomething_Click(object sender, EventArgs args)
        {
            this.SafeExecute(() =>
                {
                    if (!this.ValidateRecursively())
                    {
                        throw new ApplicationException("Data not valid");
                    }

                    throw new ApplicationException("Success");
                });
        }
        
    }
}